package com.abao.spring5;
import cn.hutool.core.lang.Console;

import java.lang.reflect.Proxy;

/**
 * @author abao
 * @date 2021-01-18
 */
public class JDKProxy {
    public static void main(String[] args) {
        //创建接口实现类的代理对象
        Class[] interfaces={UserDao.class};
        UserDao userDao=new UserDaoImpl();
        UserDao dao = (UserDao)Proxy.newProxyInstance(JDKProxy.class.getClassLoader(), interfaces, new UserProxy(userDao));
        int add = dao.add(1, 2);
        Console.log("add方法执行结果："+add);

    }

}
